其實內容腳本的用途很廣, 只是我一直沒深入去使用它,
舉凡是 過濾網頁上廣告的 Adblock Plus
或是 改善網頁瀏覽體驗的 Clearly
都能在 manifest.json 看到 content_scripts 的蹤跡.

這次範例是將 http://ithelp.ithome.com.tw/* 當作示範,
除了將網站背景改了顏色,
還對整個 body 增加了 click 事件,
寫起來不難, 但能應用的地方很多!!
manifest.json
{
   "manifest_version": 2,
   "name": "ironman6",
   "version": "1.0",  
   "content_scripts": [{
      "matches": ["http://ithelp.ithome.com.tw/*"],
      "css": ["mystyles.css"],
      "js": ["app.js"]
   }]
}
mystyles.css
body {
    background: beige;
}
app.js
document.body.addEventListener('click', function(){
	alert(Date());
});